package com.bbx.taxi.client.Listener;

import com.bbx.taxi.client.MyApplication;
import com.bbx.taxi.client.Service.LoginService;
import com.bbx.taxi.client.Util.IsServiceRunning;
import com.bbx.taxi.client.Util.ServiceRunning;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/** 
 * @Path com.bbx.taxi.client.Listener.TimeTickReceiver.java
 * @Author 严旭文
 * @Date 2016-1-7 下午5:20:36
 * @Company 蓝海（福建）信息技术有限公司
 * @Description
 */
public class TimeTickReceiver extends BroadcastReceiver {  
    
    private boolean flag;  
  
    @Override  
    public void onReceive(Context context, Intent intent) {  
//      System.out.println("时间变了" + intent.getAction());  
  
        if (intent.getAction().equals(Intent.ACTION_TIME_TICK)) {
            //每过一分钟 触发  
            ServiceRunning.IsServiceRunning(context, true);
        } else {  
            /* 
             * 系统bug?? 
             * android.intent.action.TIME_SET  当调整系统时间后 这个action会收到两次 
             */  
            if (flag) {  
                try {  
                	 ServiceRunning.IsServiceRunning(context, true);
                } catch (Exception e) {  
                    e.printStackTrace();  
                }  
                flag = false; //第二次置false  
            } else {  
                flag = true; //第一次置true  
            }  
              
        }  
          
      
          
    }
}  
